﻿using System;
using System.Collections.Generic;

using BizElements.Core;

namespace BizElements.BusinessLayer
{
    /// <summary>Contains information about field security access permissions and other metadata.</summary>
    public sealed class FieldPermissionSet
    {
        /// <summary>Initializes a new instance of <b>FieldMetadata</b> class.</summary>
        /// <param name="propertyName">Property name to which security acces rules are applied.</param>
        internal FieldPermissionSet(string propertyName)
        {
            if (string.IsNullOrEmpty(propertyName))
                throw new ArgumentNullException("propertyName");

            this.PropertyName = propertyName;
        }

        /// <summary>Initializes a new instance of <b>FieldMetadata</b> class.</summary>
        /// <param name="propertyName">Property name to which security acces rules are applied.</param>
        /// <param name="createPermission">Property name to which security acces rules are applied.</param>
        /// <param name="readPermission">Permission/action ID required to fill field when creating a new entity.</param>
        /// <param name="updatePermission">Permission/action ID required to change field value of an existing entity.</param>
        public FieldPermissionSet(string propertyName, object createPermission, object readPermission, object updatePermission)
        {
            if (string.IsNullOrEmpty(propertyName))
                throw new ArgumentNullException("propertyName");

            this.PropertyName = propertyName;
            this.CreatePermission = createPermission;
            this.ReadPermission = readPermission;
            this.UpdatePermission = updatePermission;
        }

        /// <summary>Property name to which security acces rules are applied.</summary>
        public string PropertyName { get; private set; }
        
        /// <summary>Permission/action ID required to fill field when creating a new entity.</summary>
        public object CreatePermission { get; internal set; }

        /// <summary>Permission/action ID required to read field value of an existing entity.</summary>
        public object ReadPermission { get; internal set; }

        /// <summary>Permission/action ID required to change field value of an existing entity.</summary>
        public object UpdatePermission { get; internal set; }
    }
}